require.config({
    baseUrl:"./modules",
    paths:{
        jq:"../libs/jquery",
        cookie:"../libs/cookie",
        getData:"getData_list",
        load:"list_load",
        render:"list_render",
        setLocalStorage:"setLocalStorage_list",
        setCookie:"setCookie_list"

    }
})

require(["getData","load","render","setLocalStorage","setCookie","jq","cookie",],function(getData,load,render,setLocalStorage,setCookie,_,__){
        // console.log($);

    const url = "http://localhost:3000/api?type=getGoods";
    const cont = document.querySelector(".container-left-u")
        //jq获取class时要用[数字]表示哪一个
        // console.log($(".container-left-u"))
        //   ↓↑↓↑↓↑↓↑↓获取的目标相同↑↓↑↓↑↓↑↓↑↓↑
        // console.log(cont);
    load(url).then((res)=>{
        //检查数据是否接受的到
        // console.log(res);

        //渲染页面
        render(res,$(".container-left-u")[0])
        //加入购物车的id存入LocalStorage
        $(".container-left-u").on("click",".container-left-l-d2-d2-s1",function(){
            if(localStorage.getItem("token") === "ok"){
                setLocalStorage($(this).parent().parent().parent().attr("index"))
            }else{
                if(confirm("您还未登录，是否前往登录？")){
                    location.href="./logon.html"
                }
            }
        })
        //点击图片跳转
        
        $(".container-left-u").on("click",".container-left-l-d1-i",function(){
            setCookie($(this).parent().parent().parent().attr("index"))
        })
    })
})